#pragma once
#include "vec.h"
#include <gl\gl.h>


namespace Util
{

	// Draw
	void drawBox(float xmin, float ymin, float zmin, 
		float xMax, float yMax, float zMax)
	{
		glBegin(GL_LINES);

		// Lower face
		glVertex3f(xmin, ymin, zmin);
		glVertex3f(xMax, ymin, zmin);

		glVertex3f(xmin, ymin, zmin);
		glVertex3f(xmin, yMax, zmin);

		glVertex3f(xmin, yMax, zmin);
		glVertex3f(xMax, yMax, zmin);

		glVertex3f(xMax, yMax, zmin);
		glVertex3f(xMax, ymin, zmin);

		// Upper face
		glVertex3f(xmin, ymin, zMax);
		glVertex3f(xMax, ymin, zMax);

		glVertex3f(xmin, ymin, zMax);
		glVertex3f(xmin, yMax, zMax);

		glVertex3f(xmin, yMax, zMax);
		glVertex3f(xMax, yMax, zMax);

		glVertex3f(xMax, yMax, zMax);
		glVertex3f(xMax, ymin, zMax);

		// Vertical line
		glVertex3f(xmin, ymin, zmin);
		glVertex3f(xmin, ymin, zMax);

		glVertex3f(xMax, ymin, zmin);
		glVertex3f(xMax, ymin, zMax);

		glVertex3f(xMax, yMax, zmin);
		glVertex3f(xMax, yMax, zMax);

		glVertex3f(xmin, yMax, zmin);
		glVertex3f(xmin, yMax, zMax);

		glEnd();
	}

	void drawBoxFace(float xmin, float ymin, float zmin, 
		float xMax, float yMax, float zMax) 
	{
		glPushMatrix();
		glTranslatef((xmin+xMax)/2, (ymin+yMax)/2, (zmin+zMax)/2);
		glScaled(xMax-xmin, yMax-ymin, zMax-zmin);
		glBegin(GL_QUADS);

		// Front face
		glVertex3f(  0.5, -0.5, 0.5 );
		glVertex3f(  0.5,  0.5, 0.5 );
		glVertex3f( -0.5,  0.5, 0.5 );
		glVertex3f( -0.5, -0.5, 0.5 );

		// Back face
		glVertex3f(  0.5, -0.5, -0.5 );
		glVertex3f(  0.5,  0.5, -0.5 );
		glVertex3f( -0.5,  0.5, -0.5 );
		glVertex3f( -0.5, -0.5, -0.5 );

		// Purple side - RIGHT
		glVertex3f( 0.5, -0.5, -0.5 );
		glVertex3f( 0.5,  0.5, -0.5 );
		glVertex3f( 0.5,  0.5,  0.5 );
		glVertex3f( 0.5, -0.5,  0.5 );

		// Green side - LEFT
		glVertex3f( -0.5, -0.5,  0.5 );
		glVertex3f( -0.5,  0.5,  0.5 );
		glVertex3f( -0.5,  0.5, -0.5 );
		glVertex3f( -0.5, -0.5, -0.5 );

		// Blue side - TOP
		glVertex3f(  0.5,  0.5,  0.5 );
		glVertex3f(  0.5,  0.5, -0.5 );
		glVertex3f( -0.5,  0.5, -0.5 );
		glVertex3f( -0.5,  0.5,  0.5 );

		// Red side - BOTTOM
		glVertex3f(  0.5, -0.5, -0.5 );
		glVertex3f(  0.5, -0.5,  0.5 );
		glVertex3f( -0.5, -0.5,  0.5 );
		glVertex3f( -0.5, -0.5, -0.5 );

		glEnd();
		glPopMatrix();
	}


}
